package com.shyb.lingxian.mine.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.shyb.lingxian.R;
import com.shyb.lingxian.Util.CleanMessageUtil;
import com.shyb.lingxian.Util.ToastUtil;
import com.shyb.lingxian.base.BaseActivity;
import com.shyb.lingxian.mine.presenter.SetActivityPresenter;
import com.shyb.lingxian.mine.view.SetActivityView;

/**
 * Created by gs on 2018/3/26.
 */

public class SetActivity extends BaseActivity<SetActivityPresenter> implements View.OnClickListener,SetActivityView{

    private LinearLayout set_clean;
    private LinearLayout set_aboutus;
    private LinearLayout set_fankui;
    private Button set_quit_login;
    private TextView kefuPhone;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);

        initHeadTitle("设置");

        findViews();

    }

    private void findViews() {
        set_clean = (LinearLayout) findViewById(R.id.set_clean);
        set_aboutus = (LinearLayout) findViewById(R.id.set_aboutus);
        set_fankui = (LinearLayout) findViewById(R.id.set_fankui);
        set_quit_login = (Button) findViewById(R.id.set_quit_login);
        kefuPhone = (TextView) findViewById(R.id.kefuPhone);

        set_clean.setOnClickListener(this);
        set_aboutus.setOnClickListener(this);
        set_fankui.setOnClickListener(this);
        set_quit_login.setOnClickListener(this);
        kefuPhone.setOnClickListener(this);
    }

    @Override
    protected SetActivityPresenter initPresenter() {
        return new SetActivityPresenter(this);
    }

    @Override
    protected void initialize() {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.set_clean:    //清楚缓存
                CleanMessageUtil.clearAllCache(this);
                ToastUtil.showToast(this, "清除缓存成功");

                break;

            case R.id.set_aboutus:      //关于我们
                startActivity(new Intent(this,AboutUsWebVActivity.class));
                break;

            case R.id.set_fankui:      //意见反馈
                startActivity(new Intent(this,FanKuiActivity.class));
                break;

            case R.id.set_quit_login:      //退出登录

                break;

            case R.id.kefuPhone:      //客服热线
                String phone = kefuPhone.getText().toString();
                if (phone.length() >0){
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone));
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
                break;


        }
    }

    @Override
    public void onError(String message) {
        ToastUtil.showToast(this,message);
    }
}
